#ifndef ADAPTER_H_
#define ADAPTER_H_

#include "object.h"

// TextView is treated as existing class.
// **Adapter is to use the existing class of TextView.

// public  inherit the interface class
// private inherit the implement class
class ShapeTextClassAdapter : 
	public Shape, private TextView
{
public:
	ShapeTextClassAdapter() : Shape(), TextView() {}

public:
	void getBoundPoint(
		Point& bottomLeft, Point& topRight)
	{
		Point origin;
		Coord width;
		Coord height;

		TextView::getOrigin(origin);
		TextView::getExtent(width, height);

		bottomLeft = origin;

		topRight.x = bottomLeft.x + width;
		topRight.y = bottomLeft.y + height;
	}

	void setBoundPoint(
		const Point& bottomLeft, const Point& topRight)
	{
		Point origin;
		Coord width;
		Coord height;

		origin = bottomLeft;

		width = topRight.x - bottomLeft.x;
		height = topRight.y - bottomLeft.y;

		TextView::setOrigin(origin);
		TextView::setExtent(width, height);
	}

	virtual void getText(std::string& str)
	{
		TextView::getText(str);
	}

	virtual void setText(const std::string& str)
	{
		TextView::setText(str);
	}

	virtual bool isEmpty()
	{
		return TextView::isEmpty();
	}
};

class ShapeTextObjectAdapter : public Shape
{
public:
	ShapeTextObjectAdapter(TextView* pTextView) : Shape()
	{
		m_pTextView = pTextView;
	}

public:
	void getBoundPoint(
		Point& bottomLeft, Point& topRight)
	{
		Point origin;
		Coord width;
		Coord height;

		m_pTextView->getOrigin(origin);
		m_pTextView->getExtent(width, height);

		bottomLeft = origin;

		topRight.x = bottomLeft.x + width;
		topRight.y = bottomLeft.y + height;
	}

	void setBoundPoint(
		const Point& bottomLeft, const Point& topRight)
	{
		Point origin;
		Coord width;
		Coord height;

		origin = bottomLeft;

		width = topRight.x - bottomLeft.x;
		height = topRight.y - bottomLeft.y;

		m_pTextView->setOrigin(origin);
		m_pTextView->setExtent(width, height);
	}

	virtual void getText(std::string& str)
	{
		m_pTextView->getText(str);
	}

	virtual void setText(const std::string& str)
	{
		m_pTextView->setText(str);
	}

	virtual bool isEmpty()
	{
		return m_pTextView->isEmpty();
	}

private:
	TextView* m_pTextView;
};

#endif // ADAPTER_H_
